﻿<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
    <configSections>
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net-net-1.0"/>
    </configSections>
<log4net> 
    <root>
    <level value="ALL" />
    <appender-ref ref="LogFileAppender" />
    <appender-ref ref="ConsoleAppender" />
  </root>
  <logger name="testApp.Logging">
    <level value="DEBUG"/>
  </logger>
  <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
    <param name="File" value="log-file.log" />
    <param name="AppendToFile" value="true" />
    <param name="MaxSizeRollBackups" value="12"/>
    <!-- 切割最多文件数 -->
    <param name="MaximumFileSize" value="500KB"/>

    <datePattern value="yyyyMMdd-HH:mm:ss" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="记录时间:[ %d ] 消息类型:[ %-5p ]信息内容[ %m ]%n"  />
    
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
      <param name="LevelMin" value="DEBUG" />
      <param name="LevelMax" value="WARN" />
    </filter>

  </appender>
  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">

    <connectionType value="System.Data.SqlClient.SqlConnection, System.Data" />
    <connectionString value="data source=.;database=CMS_Catering;user id=sa;password=wq_793352;" />
    <commandText value="INSERT INTO test_log([LogTime],[level],Content) VALUES (@LogTime,@level,@Content)" />
    <parameter>
      <parameterName value="@LogTime" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
    </parameter>

    <parameter>
      <parameterName value="@level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout" value="%level" />
    </parameter>

    <parameter>
      <parameterName value="@Content" />
      <dbType value="String" />
      <size value="1000" />
      <layout type="log4net.Layout.PatternLayout" value="%message" />
    </parameter>
  </appender>

  </log4net>
</configuration>



